<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<meta name="format-detection" content="telephone=no"/>
	<title>新华保险培训微平台</title>
	<link rel="stylesheet" href="../css/lt_common.css">
	<link rel="stylesheet" href="../css/iscroll.css">
	<link rel="stylesheet" href="../css/focus_person.css">
</head>
<body>
	<div class="page">
        <div id="wrapper">
            <div id="scroller">
                <div id="pullDown" >
                    <span class="pullDownIcon"></span><span class="pullDownLabel">下拉刷新...</span>
                </div>
                <ul class="star_list" id="thelist">
                    <!--<a href="personal_page.html">-->
                        <!--<li class="teacher_items">-->
                            <!--<img src="../img/da_default.png" alt=""/>-->
                            <!--<div class="infor_content">-->
                                <!--<h3>李<i class="icon_guan"></i></h3>-->
                                <!--<p class="level">明星讲师&一级一档</p>-->
                                <!--<p class="focused_num"><i class="icon_head"></i>13041</p>-->
                            <!--</div>-->
                        <!--</li>-->
                    <!--</a>-->
                </ul>
                <div id="pullUp">
                    <span class="pullUpIcon"></span><span class="pullUpLabel">查看更多>></span>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script src="../js/jquery.js"></script>
<script src="../js/common.js"></script>
<script src="../js/iscroll.js"></script>

<script src="../js/teacherclub/focus_person.js"></script>
<!--加载更多&&下拉刷新-->
<script type="text/javascript">

    var myScroll,
        pullDownEl, pullDownOffset,
        pullUpEl, pullUpOffset;

    function pullDownAction () {
        setTimeout(function () {	// <-- Simulate network congestion, remove setTimeout from production!
            var el, li, i;
            var creatTime = $('#thelist a:first-child input').val();
            el = document.getElementById('thelist');
            if(listType == "voate_teacher"){
                return;
            }else {
                $.ajax({
                    type: "GET",
                    url: API_URL+"&operation=down&createtime_time="+creatTime,
                    dataType: "json",
                    success: function (Obj) {
                        var myData = Obj.basedata.data;
                        var Str = "";
                        for (var i = 0; i < myData.length; i++) {
                            var agentItem = myData[i];
                            //默认头像
                            if (agentItem.icon == null || agentItem.icon == '') {
                                agentItem.icon = '../img/default.png';
                            }
                            //判断讲师
                            var agent_category = '';
                            if (agentItem.agent_category == 0) {
                                agent_category = "普通";
                            } else if (agentItem.agent_category == 1) {
                                agent_category = "明星讲师";
                            } else if (agentItem.agent_category == 2) {
                                agent_category = "品牌讲师";
                            } else if (agentItem.agent_category == 3) {
                                agent_category = "总公司";
                            }
                            var agent_level = '';
                            if(agentItem.agent_level == null || agentItem.agent_level ==''){
                                agent_level ='';
                            }else {
                                if (agent_category == '') {
                                    agent_level = agentItem.agent_level;
                                }else {
                                    agent_level = '&' + agentItem.agent_level;
                                }
                            }
                            Str += '<a href="personal_page.html">' +
                                    '<li class="teacher_items">' +
                                    '<img src="' + agentItem.icon + '" alt=""/>' +
                                    '<div class="infor_content">' +
                                    '<h3>' + agentItem.name + '<i class="icon_guan"></i></h3>' +
                                    '<p class="level">' + agent_category + agentItem.agent_level + '</p>' +
                                    '<p class="focused_num"><i class="icon_head"></i>' + agentItem.agent_fans_count + '</p>' +
                                    '</div>' +
                                    '</li>' +
                                    '<input type="hidden" value="'+agentItem.createtime_time+'">'+
                                    '</a>';
                        }
                        $('#thelist a:first-child').before(Str);
                    }
                });
            }

            myScroll.refresh();		// Remember to refresh when contents are loaded (ie: on ajax completion)
        }, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
    }

    function pullUpAction () {
        setTimeout(function () {	// <-- Simulate network congestion, remove setTimeout from production!
            var el, li, i;
            var creatTime = $('#thelist a:last-child input').val();
            el = document.getElementById('thelist');
            if(listType == "voate_teacher"){
                return;
            }else {
                $.ajax({
                    type: "GET",
                    url: API_URL+"&operation=down&createtime_time="+creatTime,
                    dataType: "json",
                    success: function (Obj) {
                        var myData = Obj.basedata.data;
                        var Str = "";
                        for (var i = 0; i < myData.length; i++) {
                            var agentItem = myData[i];
                            //默认头像
                            if (agentItem.icon == null || agentItem.icon == '') {
                                agentItem.icon = '../img/default.png';
                            }
                            //判断讲师
                            var agent_category = '';
                            if (agentItem.agent_category == 0) {
                                agent_category = "普通";
                            } else if (agentItem.agent_category == 1) {
                                agent_category = "明星讲师";
                            } else if (agentItem.agent_category == 2) {
                                agent_category = "品牌讲师";
                            } else if (agentItem.agent_category == 3) {
                                agent_category = "总公司";
                            }
                            var agent_level = '';
                            if(agentItem.agent_level == null || agentItem.agent_level ==''){
                                agent_level ='';
                            }else {
                                if (agent_category == '') {
                                    agent_level = agentItem.agent_level;
                                }else {
                                    agent_level = '&' + agentItem.agent_level;
                                }
                            }
                            Str += '<a href="personal_page.html">' +
                                    '<li class="teacher_items">' +
                                    '<img src="' + agentItem.icon + '" alt=""/>' +
                                    '<div class="infor_content">' +
                                    '<h3>' + agentItem.name + '<i class="icon_guan"></i></h3>' +
                                    '<p class="level">' + agent_category + agent_level + '</p>' +
                                    '<p class="focused_num"><i class="icon_head"></i>' + agentItem.agent_fans_count + '</p>' +
                                    '</div>' +
                                    '</li>' +
                                    '<input type="hidden" value="'+agentItem.createtime_time+'">'+
                                    '</a>';
                        }
                        $('#thelist a:last-child').before(Str);
                    }
                });
            }

            myScroll.refresh();		// Remember to refresh when contents are loaded (ie: on ajax completion)
        }, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
    }

    function loaded() {
        pullDownEl = document.getElementById('pullDown');
        pullDownOffset = pullDownEl.offsetHeight;
        pullUpEl = document.getElementById('pullUp');
        pullUpOffset = pullUpEl.offsetHeight;

        myScroll = new iScroll('wrapper', {
            useTransition: true,
            topOffset: pullDownOffset,
            onRefresh: function () {
                if (pullDownEl.className.match('loading')) {
                    pullDownEl.className = '';
                    pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉刷新...';
                } else if (pullUpEl.className.match('loading')) {
                    pullUpEl.className = '';
                    pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载更多...';
                }
            },
            onScrollMove: function () {
                if (this.y > 5 && !pullDownEl.className.match('flip')) {
                    pullDownEl.className = 'flip';
                    pullDownEl.querySelector('.pullDownLabel').innerHTML = '释放刷新...';
                    this.minScrollY = 0;
                } else if (this.y < 5 && pullDownEl.className.match('flip')) {
                    pullDownEl.className = '';
                    pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉刷新...';
                    this.minScrollY = -pullDownOffset;
                } else if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {
                    pullUpEl.className = 'flip';
                    pullUpEl.querySelector('.pullUpLabel').innerHTML = '释放刷新...';
                    this.maxScrollY = this.maxScrollY;
                } else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
                    pullUpEl.className = '';
                    pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载更多...';
                    this.maxScrollY = pullUpOffset;
                }
            },
            onScrollEnd: function () {
                if (pullDownEl.className.match('flip')) {
                    pullDownEl.className = 'loading';
                    pullDownEl.querySelector('.pullDownLabel').innerHTML = '加载中...';
                    pullDownAction();	// Execute custom function (ajax call?)
                } else if (pullUpEl.className.match('flip')) {
                    pullUpEl.className = 'loading';
                    pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载中...';
                    pullUpAction();	// Execute custom function (ajax call?)
                }
            }
        });

        setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 800);
    }

    document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

    document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);
</script>
